clear
%cd ('W:\Projects\Hoffmann_Shcherbakova\Programs_RES')
format('bank');

%%Table 4 
display('     Table 4: Risk Sharing, Banking Deregulation and Business Cycle')
display('                      Panel A')
disp('  ')

state_group='all';
s=1;
T=42;
Main_preparation

M=[dy(s:s+T-1,1:K),dy(s:s+T-1,1:K).*Intra(s:s+T-1,1:K),ones(size(dgsp)) ,Intra(s:s+T-1,1:K)];%
NL=Intra(s:s+T-1,1:K);% switch on for table 4 to include c_x into
%regression

if ~exist('estimator')
     estimator='OLS';
 end
 
 if ~exist('channel')
     channel='all';
 end
 
 Main
 
 display('    ')
 display('                      Panel B')
M=[NBERPeak(s+1:s+T,:)*ones(1,K),NBERTrough(s+1:s+T,:)*ones(1,K),(NBERPeak(s+1:s+T,:)*ones(1,K)).*Intra(s:s+T-1,1:K),(NBERTrough(s+1:s+T,:)*ones(1,K)).* Intra(s:s+T-1,1:K),ones(size(dgsp)),Intra(s:s+T-1,1:K)];%  
NL=Intra(s:s+T-1,1:K);% switch on for table 4 to include c_x into

Main

display('  ')
display('F-Test of H0: Deregulation removes cyclicality in risk sharing in booms')
varI=IAR_Cl.ClusterReg{1}(:,4:end);
varF=IAR_Cl.ClusterReg{2}(:,4:end);
varC=IAR_Cl.ClusterReg{3}(:,4:end);
varU=IAR_Cl.ClusterReg{4}(:,4:end);
[FtestI,DI,PValI]=Ftest(IAR_Cl.b(:,1),[0,1,0,1,0,0,0],varI,size(Y_channels,1),0);%ich hatte aus versehen
[FtestF,DF,PValF]=Ftest(IAR_Cl.b(:,2),[0,1,0,1,0,0,0],varF,size(Y_channels,1),0);%IAR_Cl.b(:,4)
[FtestC,DC,PValC]=Ftest(IAR_Cl.b(:,3),[0,1,0,1,0,0,0],varC,size(Y_channels,1),0);% f�r jede beta
[FtestU,DU,PValU]=Ftest(IAR_Cl.b(:,4),[0,1,0,1,0,0,0],varU,size(Y_channels,1),0);%gehabt
Ftest=[FtestI,FtestF,FtestC,FtestU];
PVal=[PValI,PValF,PValC,PValU];
display(Ftest)
display(PVal)

clear Ftest* D* PVal*

display('  ')
display('F-Test of H0: Deregulation removes cyclicality in risk sharing in recessions')
[FtestI,DI,PValI]=Ftest(IAR_Cl.b(:,1),[0,0,1,0,1,0,0],varI,size(Y_channels,1),0);%ich hatte aus versehen
[FtestF,DF,PValF]=Ftest(IAR_Cl.b(:,2),[0,0,1,0,1,0,0],varF,size(Y_channels,1),0);%IAR_Cl.b(:,4)
[FtestC,DC,PValC]=Ftest(IAR_Cl.b(:,3),[0,0,1,0,1,0,0],varC,size(Y_channels,1),0);% f�r jede beta
[FtestU,DU,PValU]=Ftest(IAR_Cl.b(:,4),[0,0,1,0,1,0,0],varU,size(Y_channels,1),0);%gehabt
Ftest=[FtestI,FtestF,FtestC,FtestU];
PVal=[PValI,PValF,PValC,PValU];
display(Ftest)
display(PVal)




 
 